package comm.parsers;

import java.util.ArrayList;

import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;

public class NaverSuggestResultSAXParserHandler extends DefaultHandler {
	  private StringBuffer items = new StringBuffer();
	  private boolean isItem = false;
	  public ArrayList itemList = new ArrayList();
	  public int itemNum=1;
	  
	  public ArrayList getItemList(){
		  return itemList;
	  }
	  
	  public void startElement(String uri, String localName,
	                     String qName, Attributes atts)
	  {
	      if (qName.equals("item")) {
	    	  isItem=true;  items.setLength(0); 
	      }
	  }
	  public void endElement(String uri, String localName,
	                     String qName)
	 { 
	      if (qName.equals("item")&&items!=null){
	    	  
	    	  itemList.add(items.toString());
	    	  
	    	  itemNum++;
	      }
	  }
	  public void characters(char[] chars, int start, int leng) 
	  {  
	      if (isItem) {
	    	  isItem=false;  items.append(chars,start,leng);
	      }
	  }
	
}
